import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;

public class Main819 {
    public static void main(String[] args) {
        MyThread myThread = new MyThread();
        System.out.println("启动线程");
        myThread.start();

        MyRunnable myRunnable = new MyRunnable();
        myRunnable.run();

        FutureTask<Integer> myCallableFutureTask = new FutureTask<Integer>(new MyCallable());
        myCallableFutureTask.run();

        ThreadPool threadPool = new ThreadPool();
        threadPool.start();
    }
    static class MyThread extends Thread{
        @Override
        public void run() {
            for (int i = 0;i< 10;i++){
                System.out.println("thread <:"+i);
            }
        }
    }
    static class MyRunnable implements Runnable{

        @Override
        public void run() {
            for (int i = 0;i< 10;i++){
                System.out.println("runnable <:"+i);
            }
        }
    }
    static class MyCallable implements Callable<Integer>{

        @Override
        public Integer call() throws Exception {
            for (int i = 0;i< 10;i++){
                System.out.println("callable <:"+i);
            }
            return 1+1;
        }
    }
    static class ThreadPool{
        ExecutorService service = Executors.newFixedThreadPool(2);
        public void start(){
            service.submit(new Runnable() {
                @Override
                public void run() {
                    for (int i = 0;i< 10;i++){
                        System.out.println("pool <:"+i);
                    }
                }
            });
            service.shutdown();
        }
    }
}

